package com.dhcc.service;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;


public class RoadNetWebService {
	
	//static String ServerAddress=Resources.getSystem().getString(R.string.serveraddress);
	
	//内网
	/*static String ServerAddress="http://172.18.18.203:8887/phone/webService";*/	
	static String ServerAddress="http://172.28.18.2:8887/phone/webService?wsdl";
	
	//外网
	// static String ServerAddress="http://114.251.193.190:8887/phone/webService";
	 
	//交通委网
		//static String ServerAddress="http://172.24.186.187:8887/phone/webService";
		public static String getRoadNetString(String functionName) {//获得路网信息的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = true;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
			
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
		
		public static String getRainBowReportString(String functionName,String date,String road) {//获得航班报表数据的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				
				rpc.addProperty("arg0", date);
				rpc.addProperty("arg1", road);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = false;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
				
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
		public static String getTrafficAreaIndexReport(String functionName) {//获得城区交通指数的柱状图值
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = true;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
}
